<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    var isValidBST = function (root) {
      return dfs(root, -Infinity, Infinity)
    };
    function dfs(root, min, max) {
      if (!root) return true
      if (root.val >= max || root.val <= min) return false
      return dfs(root.left, min, root.val)
        && dfs(root.right, root.val, max)
    }
    console.log(isValidBST([5,1,4,null,null,3,6]));
  </script>
</body>

</html>